﻿@model CREAPA.Dominio.Funcionario

@{
    ViewBag.Title = "Alterar";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="~/Scripts/js/JavaScriptUtil.js"></script>
     <script src="~/Scripts/js/Parsers.js"></script>
<script src="~/Scripts/js/original/InputMask.js"></script>
<script src="~/Scripts/AlertaPersonalizado.js"></script>
     

<script language="javascript">
    function setup() {
        var phoneMask = new InputMask("(##) #####-####", "Pessoa_Fone");
        var cpfMask = new InputMask("###.###.###-##", "Pessoa_CPF");
        var emailMask = new InputMask([fieldBuilder.lowerLetters(), fieldBuilder.literal(String.fromCharCode(64) + "creapa.com.br")], "Pessoa_Email");
        var cargaHoMask = new InputMask(fieldBuilder.inputNumbers(), "CargaHo");
        var errorMessage = "Data Invalida: ${value}. Formato Esperado: ${mask}";
        var DtNasc = new DateMask("dd/MM/yyyy", "DtNasc");
        DtNasc.validationMessage = errorMessage;
        var DtAdm = new DateMask("dd/MM/yyyy", "DtAdm");
        DtAdm.validationMessage = errorMessage;

    }
</script>

<style>
		h1 {
			margin-bottom: 1rem;
		}

		* {
			margin: 0;
			padding: 0;
		}

        fieldset.grupo {
			border: 0;
		}

		
		body, input, select, textarea, button {
			font-family: sans-serif;
			font-size: 1em;
		}

		.grupo:after {
			content: "."; 
			display: block; 
			height: 0;
			clear: both; 
			visibility: hidden;
            
		}

		.campo {
			margin-bottom: 1em;
		}
        
        .campo2 {
			margin-bottom: 1em;
		}
        
        fieldset.grupo .campo2 {
			margin-right: 5em;
		}

		.campo2 label {
			margin-bottom: 0.2em;
			color: #000;
			display: block;
            margin-left: 3px;
		}
        
        .campo label {
			margin-bottom: 0.2em;
			color: #000;
			display: block;
            margin-left: 3px;
		}

		fieldset.grupo .campo {
			float: left;
			margin-right: 5em;
		}

		.campo input[type="text"],
		.campo input[type="email"],
		.campo input[type="url"],
		.campo input[type="tel"],
		.campo select,
		.campo textarea {
			padding: 0.2em;
			border: 1px solid #CCC;
			box-shadow: 2px 2px 2px rgba(0,0,0,0.2);
			display: block;
            width: 320px;
            margin-left: 3px;
		}

		.campo select option {
			padding-right: 1em;
		}

		.campo input:focus, .campo select:focus, .campo textarea:focus {
			background: #ffffff;
		}

		.campo label.checkbox {
			color: #000;
			display: inline-block;
			margin-right: 1em;
		}
	
	</style>

@{
    if(TempData["RedefinirSenha"] != null) {
        TempData["RedefinirSenha"] = null;
        <body onload="Alert.render('Email De Redefinição de Senha Enviado')">
        <div id="dialogoverlay"></div>
        <div id="dialogbox"><div>
        <div id="dialogboxhead"></div>
        <div id="dialogboxbody"></div>
        <div id="dialogboxfoot"></div>
        </div>
        </div>
        </body>
}
}
<fieldset>
<h2>Alterar Funcionario</h2>

@using (Html.BeginForm("Alterar", "Funcionario", FormMethod.Post,
          new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
<body onload="setup()">
    <fieldset class="grupo">
        <legend><b>Funcionario</b></legend>
            @Html.HiddenFor(model => model.Login)

            <div class="login-msg">
            <div class="campo">
            @Html.LabelFor(model => model.Pessoa.Nome)
            @Html.EditorFor(model => model.Pessoa.Nome)
            @Html.ValidationMessageFor(model => model.Pessoa.Nome)
        </div>
        <div class="login-msg">
        <div class="campo">
            @Html.LabelFor(model => model.Matricula)
            @Html.EditorFor(model => model.Matricula)
            @Html.ValidationMessageFor(model => model.Matricula)
        </div>

            <div class="login-msg">
            <div class="campo">
             @Html.LabelFor(model => model.Rg)
            @Html.EditorFor(model => model.Rg)
            @Html.ValidationMessageFor(model => model.Rg)
        </div>
</fieldset>
        <fieldset class="grupo">
        <div class="login-msg">
        <div class="campo">
            @Html.LabelFor(model => model.Pessoa.CPF)
            @Html.EditorFor(model => model.Pessoa.CPF)
            @Html.ValidationMessageFor(model => model.Pessoa.CPF)
        </div>
        <div class="login-msg">
        <div class="campo">
            @Html.LabelFor(model => model.Login)    
            @Html.TextBoxFor(model => model.Login, new {@readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.Login)
        </div>
        <div class="login-msg">
            <div class="campo">
            @Html.LabelFor(model => model.DtNasc)
            @Html.EditorFor(model => model.DtNasc)
            @Html.ValidationMessageFor(model => model.DtNasc)
        </div>
</fieldset>
            <fieldset class="grupo">
             <div class="login-msg">
            <div class="campo">
            @Html.LabelFor(model => model.Pessoa.Email)
            @Html.EditorFor(model => model.Pessoa.Email)
            @Html.ValidationMessageFor(model => model.Pessoa.Email)
        </div>
            <div class="login-msg">
            <div class="campo">
            @Html.LabelFor(model => model.Pessoa.Fone)
            @Html.EditorFor(model => model.Pessoa.Fone)
            @Html.ValidationMessageFor(model => model.Pessoa.Fone)
        </div>

        <div class="login-msg">
        <div class="campo">
            @Html.LabelFor(model => model.ctps_serie)
            @Html.EditorFor(model => model.ctps_serie)
            @Html.ValidationMessageFor(model => model.ctps_serie)
        </div>
        </fieldset>

            <fieldset class="grupo">
            <div class="login-msg">
            <div class="campo">
            @Html.LabelFor(model => model.Cbo)
            @Html.EditorFor(model => model.Cbo)
            @Html.ValidationMessageFor(model => model.Cbo)
        </div>
        <div class="login-msg">
        <div class="campo">
            @Html.LabelFor(model => model.Pis)
            @Html.EditorFor(model => model.Pis)
            @Html.ValidationMessageFor(model => model.Pis)
        </div>
            <div class="login-msg">
            <div class="campo">
            @Html.LabelFor(model => model.CargaHo)
            @Html.EditorFor(model => model.CargaHo)
            @Html.ValidationMessageFor(model => model.CargaHo)
        </div>
        </fieldset>
            <fieldset class="grupo">
            <div class="login-msg">
            <div class="campo">
            @Html.LabelFor(model => model.DtAdm)
            @Html.EditorFor(model => model.DtAdm)
            @Html.ValidationMessageFor(model => model.DtAdm)
        </div>
        </fieldset>
        <fieldset class="grupo">
        <div class="login-msg">
        <div class="campo2" style="margin-left: 3px;">
            @Html.LabelFor(model => model.IdInsp)
            @Html.DropDownList("IdInsp",  "Selecione")      
            @Html.ValidationMessageFor(model => model.IdInsp)
        </div>

        <div class="login-msg">
        <div class="campo2" style="margin-left: 3px;">
            @Html.LabelFor(model => model.Setor)
            @Html.DropDownList("Setor",  "Selecione")      
            @Html.ValidationMessageFor(model => model.Setor)
        </div>
     
        <div class="login-msg">
        <div class="campo2" style="margin-left: 3px;">
            @Html.LabelFor(model => model.IdCargo)
            @Html.DropDownList("IdCargo",  "Selecione")      
            @Html.ValidationMessageFor(model => model.IdCargo)
        </div>
            </div>

            <div class="campo2" style="margin-left: 3px;">
            @Html.LabelFor(model => model.Pessoa.Ativo)
            @Html.CheckBoxFor(model => model.Pessoa.Ativo, new { @checked = "checked" })
            @Html.ValidationMessageFor(model => model.Pessoa.Ativo)
        </div>

            
           
            <div class="campo2" style="margin-left: 3px;">

            @Html.LabelFor(model => model.Assinatura)
            
                <img src="@Url.Action("GetImage", "Funcionario", new { Login = Model.Login})" alt="Nenhuma imagem cadastrada" width="80" height="50"/>             

            </div>             

        <div class="login-msg">
        <div class="campo2" style="margin-left: 3px;">
             Selecione o arquivo com a assinatura: 
            <input type="file" name="FileUpload1"  />
            @Html.ValidationMessageFor(model => model.Assinatura)
        </div>
        </div>

        <p>
            <input type="submit" value="Alterar" class="button" />            
            @Html.ActionLink("Permissões", "Index","FuncionarioPermissao", new {Login = Model.Login},new { @class = "button2"})
            @Html.ActionLink("Setores", "Index","FuncionarioSetor", new {Login = Model.Login},new { @class = "button2"})
            @Html.ActionLink("Dossie", "Index","Dossie", new {Login = Model.Login},new { @class = "button2"})
            @Html.ActionLink("Redefinir Senha", "RedefinirSenha","Funcionario", new {Login = Model.Login},new { @class = "button2"})
            @Html.ActionLink("Voltar", "Index",null,new { @class = "button2" })
        </p>
     </fieldset>
</body>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
<script>
    jQuery(document).ready(function () {
        // verifica se existe algum elemento com a class
        if ($(".button").length) {
            // adiciona evento desabilitando o botão
            $(".button").on('click', function () {
                $(this).attr({
                    disabled: true
                });
                // descobrindo o form pai e enviando
                this.value = 'Enviando...';
                $(this).parents('form:first').submit();
            });
        }
    });
</script>